home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
020a
/
intgif11.zip
/
PARAM.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1990-07-18
|
3KB
|
108 lines
{-------------------------------------------------------------------------}
{ }
{ Param - Parameter Parsing Unit - Copyright (c) EUROPA Software, 1990 }
{ Last Alteration - October 18 }
{ }
{-------------------------------------------------------------------------}
unit param;
interface
const MaxParams = 20;
crlf = #10 + #13;
type ParamArray = RECORD
SpecCount : byte;
Spec : array[1..MaxParams] of string;
SwitchCount : byte;
Switch : array[1..MaxParams] of string;
end;
function ParseCommandLine( var CommandLine : ParamArray ) : boolean;
implementation
function ToUpCase( InString : string ) : string;
var i : byte;
st : string;
begin
st := '';
for i := 1 to length(InString) do st := st + upcase(InString[i]);
ToUpCase := st;
end;
function ParseCommandLine( var CommandLine : ParamArray ) : boolean;
var ParseCount : byte;
i,k : byte;
st : string;
begin
CommandLine.SpecCount := 0;
CommandLine.SwitchCount := 0;
for i := 1 to paramcount do begin
st := paramstr(i);
if (st[1] = '-') OR (st[1] = '/') then begin
for k := 2 to length(st) do
if CommandLine.SwitchCount < MaxParams then begin
inc(CommandLine.SwitchCount);
CommandLine.Switch[CommandLine.SwitchCount] := st[k];
end
else begin
ParseCommandLine := false;
exit;
end;
end
else begin
if CommandLine.SpecCount < MaxParams then begin
inc(CommandLine.SpecCount);
CommandLine.Spec[CommandLine.SpecCount] := ToUpCase(st);
end
else begin
ParseCommandLine := false;
exit;
end;
end;
ParseCommandLine := true;
end;
end;
begin
end.